import java.util.ArrayList;

public class DataCenter {
	private String name;
	private int id;
	private double lat;
	private double lon;
	private ArrayList <PhysicalMachine> pmList;
	
	public DataCenter(String name, int id, double lat, double lon, ArrayList<PhysicalMachine> pmList) {
		this.name=name;
		this.id=id; 
		this.lat=lat;
		this.lon=lon;
		this.pmList=pmList;
	}
	
	public void setId(int id) {
		this.id=id;
	}
	public int getId() {
		return this.id;
	}
	
	public void setName(String name) {
		this.name=name;
	}
	public String getName() {
		return this.name;
	}
	
	public void setLocation(double lat, double lon) {
		this.lat=lat;
		this.lon=lon;
	}
	public double [] getLocation() {
		double [] loc={this.lat, this.lon};
		return  loc;
	}
	public void setPmList(ArrayList<PhysicalMachine> pmList) {
		this.pmList=pmList;
	}
	public ArrayList<PhysicalMachine> getPmList() {
		return  this.pmList;
	}

	public double getDistance(double lat, double lon) {
		 double R = 6371; // Radius of the earth in km
		 double dLat = Math.toRadians(lat-this.lat);  
		 double dLon = Math.toRadians(lon-this.lon); 
		 double a = 
		    Math.sin(dLat/2) * Math.sin(dLat/2) +
		    Math.cos(Math.toRadians(this.lat)) * Math.cos(Math.toRadians(lat)) * 
		    Math.sin(dLon/2) * Math.sin(dLon/2);

		 double c = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1-a)); 

		 return R * c; // Distance in km
		
	}
	
}